/*  */
$(function(){
    $dealer = $('#popDealerModal'),
    $dealerIput = $('#dealerIput'),
    $dealerPop = $('#dealerModal');
    App.init();
    if (jQuery().datepicker) {
        $('.date-picker').datepicker({
            language:"zh-CN",
            rtl: App.isRTL(),
            autoclose: true
        });
    }
    //ztree
    var setting = {
        edit: {
            enable: true
        },
        data: {
            simpleData: {
            enable: true
            }
        },
        callback: {
            onClick: zTreeOnClick
        }
    };
    //选择经销商弹窗树节点事件(todo)
    function zTreeOnClick(event, treeId, treeNode) {

    };
    var zNodes =[
        { id:1, pId:0, name:"上海汽车工业(集团)总公司", open:true},
        { id:11, pId:1, name:"行政大区2区_MG",open:true},
        { id:111, pId:11, name:"雪佛兰",open:true},
        { id:1111, pId:111, name:"经销商礼遇"},
        { id:112, pId:11, name:"凯迪拉克",open:true,isParent:true},
        { id:12, pId:1, name:"行政大区1区_Rw",open:true},
        { id:121, pId:12, name:"制度类"},
        { id:122, pId:12, name:"流程类"},
        { id:123, pId:12, name:"话术类"}
    ];
    $.fn.zTree.init($("#companyTree"), setting, zNodes);
    //选择购买车型弹窗
    $dealer.on("click", function(){
        $dealerPop.modal('show');
    });
    //购买车型选中赋值
    $('#dealerSubmit').on('click', function(){
        var $dealerChecked = $dealerPop.find('table tbody :radio:checked'), val;
        val = $dealerChecked.closest('tr').find('td').eq(1).text();
        $dealerIput.val( val );
        $dealerPop.modal('hide');
    });
})